package com.elead.oa.controller;

import com.elead.oa.entity.Department;
import com.elead.oa.service.department.IDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 部门管理
 * DepartmentController
 * 创建人:xiaozuolin
 * 创建时间：2021年09月28日 14:22:34
 *
 * @version 1.0.0
 */
@RestController
@RequestMapping("/department")
@Slf4j
@CrossOrigin
@Api(tags = "部门控制层")
public class DepartmentController {

    @Autowired
    private IDepartmentService departmentService;


    /**
     * 部门管理 列表页面
     *
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询所有部门信息",httpMethod = "GET",produces = "application/json",notes = "查询所有部门信息")
    public List<Department> list() {
        return departmentService.list();
    }

    /**
     * 部门管理 添加页面
     *
     * @return
     */
    @GetMapping("/add")
    public String add(Long id, ModelMap modelMap) {
        modelMap.put("id", id);
        return "admin/department/add";
    }
}
